<template>
  <div style="display: inline-block" v-if="data.cancelTips === 1 && (data.orderStatus === 4 || data.orderStatus === 5)">
    <el-button type="info" @click="cancelTips" :loading="loading">{{$t('order.Cancel prompt')}}</el-button>
  </div>
</template>

<script>
import {knowOrderCancel} from "@/api/order";

export default {
  name: "CancelTipsButton",
  props:{
    data:{
      type: Object,
    }
  },
  data(){
    return {
      loading: false,
    }
  },
  methods:{
    // 转为库存
    cancelTips(){
      this.loading = true
      knowOrderCancel(this.data.orderId)
        .then(res=>{
          this.loading = false
          if(res.error === 0){
            this.dialog = false;
            this.$successMessage(res.message)
            this.$emit('changeOrder');
            this.$store.dispatch('user/getInfo');
          }else{
            this.$errorMessage(res.message)
          }
        })
    },
  },
}
</script>

<style scoped>

</style>
